package com.weiqiao.mall.repository.impl;

import com.weiqiao.base.dao.impl.BaseMongoDaoImpl;
import com.weiqiao.mall.repository.ILabelShelfRepository;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 宝贝标签dao实现类
 * @author: xujun
 * @Date: 2019/10/31  10:39
 */
@Service("labelShelfRepository")
public class LabelShelfRepositoryImpl extends BaseMongoDaoImpl implements ILabelShelfRepository {

    /**
     * 连接名称
     */
    private static final String CONNECTION_NAME = "label_shelf_";

    /**
     * 查询 宝贝标签
     *
     * @param companyId
     * @param filter
     * @return
     */
    @Override
    public List<String> getLabelShelfList(int companyId, Bson filter) {
        return super.findFilter(CONNECTION_NAME + companyId, filter);
    }

    /**
     * 根据条件查询宝贝标签
     *
     * @param companyId
     * @param filter
     * @return
     */
    @Override
    public String getLabelShelfByFilter(int companyId, Bson filter) {
        return super.findOne(CONNECTION_NAME + companyId, filter);
    }

    /**
     * 查找并更新
     *
     * @param companyId
     * @param filter
     * @param document
     * @param bool
     * @return
     */
    @Override
    public boolean findAndUpdate(int companyId, Bson filter, Document document, boolean bool) {
        return super.updateOne(CONNECTION_NAME + companyId, filter, document, bool);
    }
}
